package yunhe.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;
import org.json.JSONObject;

import yunhe.biz.StockMgrBiz;
import yunhe.biz.impl.StockMgrBizImpl;
import yunhe.entity.Purchase;
@WebServlet(name="GetPurchaseDataServlet",urlPatterns="/GetPurchaseDataServlet")
public class GetPurchaseDataServlet extends HttpServlet
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
    doPost(req,resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
		StockMgrBiz stock=new StockMgrBizImpl();
		List<Purchase> list=stock.quryAllPurchaseMsg();
		 JSONArray  ja=new JSONArray();
		 for(Purchase s:list)
		 {
			JSONObject jo=new JSONObject(s);
			ja.put(jo);
		 }
		 resp.getWriter().print(ja.toString());

	}
	

}
